<?php
//多对多关系，需要建中间表	
//文章表arc
aid atitle
1	今天天气很好
2	明天雾霾
3	天天吃黄焖鸡，不闷？
4	宝宝你心里苦不苦 
5	中国新歌声		
//中间表
aid tid
1	1
1	5
2	1
3	2
4	3
4	4
4	6
5	3
5	6
select t.tname from arc c join center at on a.aid=at.aid join tag t on at.tid=t.tid where a.atitle='宝宝你心里苦不苦';
//标签tag
tid	tname
1	天气
2	饮食
3	娱乐	
4	马蓉 
5	后盾网
6	音乐 

//查找文章【宝宝你心里苦不苦 】所对应的标签名称
select aid from arc where atitle="宝宝你心里苦不苦";
+-----+
| aid |
+-----+
|   4 |
+-----+
select tid from arc_tag where aid=4;
+------+
| tid  |
+------+
|    3 |
|    4 |
|    6 |
+------+
select tname from tag where tid in(3,4,6);

//关联查询
(1)select * from arc a join arc_tag at on a.aid=at.aid join tag t on at.tid=t.tid;
(2)select a.atitle,t.tname from arc a join arc_tag at on a.aid=at.aid join tag t on at.tid=t.tid;
(3)select a.atitle,t.tname from arc a join arc_tag at on a.aid=at.aid join tag t on at.tid=t.tid where a.atitle="宝宝你心里苦不苦 ";
(4)select a.atitle,t.tname from arc a join arc_tag at on a.aid=at.aid join tag t on at.tid=t.tid where a.atitle="宝宝你心里苦不苦 ";















